function refresh(){
	if($("#segmentedControl").css("display") == 'none') {
		if($("#search").val()=="") {
			$(".searchDiv").hide();
			$("#segmentedControl").show();
		}
	}
	listDefect("mydef");
	listDefect("notshortcom");
	listDefect("shortcom");
	listDefect("legacy");
}

$(function(){
	listDefect("mydef");
	listDefect("notshortcom");
	listDefect("shortcom");
	listDefect("legacy");

});
var dataHand = new AjaxHandler();
var psid = param.psid;

var search = null;
function listDefect(id){
	$.proAjax({
		url: "/mobile/defect",
		data: { psid: psid, result:$("#"+id+" #params").text(),search:search},
		success: function (data) {
			dataHand.arrayAddToHtml(id,data,"cutline",function(elm,datas){
				elm.find("a").off("click");
				if(datas.result==0){
					elm.find("#result").addClass("bg-ee");
					elm.find("#result").text("未消缺");
					elm.find("#reset_1").text("设定已消缺");
					elm.find("#reset_2").text("设定有遗留");
					elm.find("#reset_1").attr("data-value","1");
					elm.find("#reset_2").attr("data-value","2");
				}else if(datas.result==1){
					elm.find("#result").addClass("bg-green");
					elm.find("#result").text("已消缺");
					elm.find("#reset_1").text("设定未消缺");
					elm.find("#reset_2").text("设定有遗留");
					elm.find("#reset_1").attr("data-value","0");
					elm.find("#reset_2").attr("data-value","2");
				}else if(datas.result==2){
					elm.find("#result").addClass("bg-tint");
					elm.find("#result").text("有遗留");
					elm.find("#reset_1").text("设定未消缺");
					elm.find("#reset_2").text("设定已消缺");
					elm.find("#reset_1").attr("data-value","0");
					elm.find("#reset_2").attr("data-value","1");
				}
				(function(m,d){
					m.parent().parent().off("tap")
					m.find(".mui-slider-handle").on("click",function(e){
						e.preventDefault();
						e.stopPropagation();
						router.href("defectEdit.html",{defid:d});
					})
				}(elm,datas.defid))
				
			});
			$(".mui-slider-right,.mui-disabled").find("a").off("click");
			$(".mui-slider-right,.mui-disabled").find("a").on("click",function(e){
				e.preventDefault();
				e.stopPropagation();
				var result = $(this).attr("data-value");
				var defid = $(this).parent().prev().text();
				var divs = $(this).closest("li").attr("data-list");
				var btnArray = ['取消','确定'];
				if($(this).text()=="删除"){
					mui.confirm('删除后无法恢复，确认删除？', '提示', btnArray, function(e) {
						if(e.index==1){
							$.proAjax({
								url: "/mobile/upresult",
								data: { defid: defid, result:result},
								success: function (data) {
									listDefect("mydef");
									listDefect(divs);
								}
								});
						}
					})
				}else{
					$.proAjax({
						url: "/mobile/upresult",
						data: { defid: defid, result:result},
						success: function (data) {
							listDefect("mydef");
							listDefect("notshortcom");
							listDefect("shortcom");
							listDefect("legacy");
						}
						});
				}
				
			});
		}
	});
}

/*mui.plusReady(function(){
	listDefect("mydef");
	listDefect("notshortcom");
	listDefect("shortcom");
	listDefect("legacy");
});*/

